package com.xveshe.admin.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xveshe.common.annotation.Log;
import com.xveshe.common.core.controller.BaseController;
import com.xveshe.common.core.domain.AjaxResult;
import com.xveshe.common.enums.BusinessType;
import com.xveshe.admin.domain.XsglTgsq;
import com.xveshe.admin.service.IXsglTgsqService;
import com.xveshe.common.utils.poi.ExcelUtil;
import com.xveshe.common.core.page.TableDataInfo;

/**
 * 调岗调社申请Controller
 *
 * @author geyasong
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/admin/tgsq")
public class XsglTgsqController extends BaseController
{
    @Autowired
    private IXsglTgsqService xsglTgsqService;

    /**
     * 查询调岗调社申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(XsglTgsq xsglTgsq)
    {
        startPage();
        List<XsglTgsq> list = xsglTgsqService.selectXsglTgsqList(xsglTgsq);
        return getDataTable(list);
    }

    /**
     * 导出调岗调社申请列表
     */
    @Log(title = "调岗调社申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, XsglTgsq xsglTgsq)
    {
        List<XsglTgsq> list = xsglTgsqService.selectXsglTgsqList(xsglTgsq);
        ExcelUtil<XsglTgsq> util = new ExcelUtil<XsglTgsq>(XsglTgsq.class);
        util.exportExcel(response, list, "调岗调社申请数据");
    }

    /**
     * 获取调岗调社申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(xsglTgsqService.selectXsglTgsqById(id));
    }

    /**
     * 新增调岗调社申请
     */
    @Log(title = "调岗调社申请", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody XsglTgsq xsglTgsq)
    {
        return toAjax(xsglTgsqService.insertXsglTgsq(xsglTgsq));
    }

    /**
     * 修改调岗调社申请
     */
    @Log(title = "调岗调社申请", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody XsglTgsq xsglTgsq)
    {
        return toAjax(xsglTgsqService.updateXsglTgsq(xsglTgsq));
    }

    /**
     * 删除调岗调社申请
     */
    @Log(title = "调岗调社申请", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(xsglTgsqService.deleteXsglTgsqByIds(ids));
    }
}
